package rulebasedsystem;

import game.Board;

public class SingleRule {
	private Board currentBoard;
	private int color;
	private int rowToPlay;
	private int columnToPlay;
	private int ruleWeight;
	
	public SingleRule(Board currentBoard, int color, int rowToPlay, int columnToPlay) {
		this(currentBoard, color, rowToPlay, columnToPlay, 0);
	}
	
	public SingleRule(Board currentBoard, int color, int rowToPlay, int columnToPlay, int ruleWeight) {
		this.currentBoard = currentBoard;
		this.color = color;
		this.rowToPlay = rowToPlay;
		this.columnToPlay = columnToPlay;
		this.ruleWeight = ruleWeight;
	}
	
	@Override
	public boolean equals(Object obj) {
		SingleRule singleRule = (SingleRule)obj;
		return (this.getCurrentBoard().equals(singleRule.getCurrentBoard()) && this.color == singleRule.getColor() 
				&& this.columnToPlay == singleRule.getColumnToPlay() && this.rowToPlay == singleRule.getRowToPlay());
	}
	
	public void incrementRuleWeight() {
		this.ruleWeight++;
	}
	
	public SingleRule cloneSingle() {
		return new SingleRule(currentBoard.cloneBoard(), color, rowToPlay, columnToPlay);
	}
	
	public Board getCurrentBoard() {
		return currentBoard;
	}
	
	public void setCurrentBoard(Board currentBoard) {
		this.currentBoard = currentBoard;
	}

	public int getColor() {
		return color;
	}
	
	public void setColor(int color) {
		this.color = color;
	}
	
	public int getRowToPlay() {
		return rowToPlay;
	}
	
	public void setRowToPlay(int rowToPlay) {
		this.rowToPlay = rowToPlay;
	}
	
	public int getColumnToPlay() {
		return columnToPlay;
	}
	
	public void setColumnToPlay(int columnToPlay) {
		this.columnToPlay = columnToPlay;
	}
	
	public int getWeight() {
		return ruleWeight;
	}
	
	public void setWeight(int weight) {
		if(weight > 0){
			this.ruleWeight = weight;
		}
	}
}